// run: $exec < input
/*************************************************************************
	> File Name: 1006.cpp
	> Author: skt
	> Mail: sktsxy@gmail.com
	> Created Time: 2015年09月27日 星期日 13时21分37秒
 ************************************************************************/

#include <cstring>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <complex>
#include <cassert>
// #pragma comment(linker,"/STACK:102400000,102400000")
using namespace std;
#define LL long long
#define pb push_back
#define mp make_pair
#define x first
#define y second
#define lson pos << 1
#define rson pos << 1 | 1
#define MAXN 100005
template <typename T> inline void checkMax(T &a, T b) {a = a>b?a:b;}
template <typename T> inline void checkMin(T &a, T b) {a = a<b?a:b;}
typedef pair<int, int> PII;
typedef vector<int> vi;
const double PI = acos(-1.0);
const double eps = 1e-8;
const int INF = 0x3fffffff;
int T, Cas = 1, N, L, a[MAXN], A[MAXN], len[MAXN], Len[MAXN];

struct Point {
    int x;

    Point() {}

    Point(int x) : x(x) {}

    bool operator < (const Point &next) {
        return x > next.x;
    }
} b[MAXN], B[MAXN];

void init() {
    int ans = 1;
    A[0] = - INF;
    A[1] = a[1];
    len[1] = ans;
    for (int i = 2; i <= N; i ++) {
        int j = lower_bound(A + 1, A + ans + 1, a[i]) - A;
        if (j > ans) ans = j;
        A[j] = a[i];
        len[i] = j;
    }
    B[0] = Point(INF);
    B[1] = b[N];
    ans = 1;
    Len[N] = ans;
    for (int i = N - 1; i >= 1; i --) {
        int j = lower_bound(B + 1, B + ans + 1, b[i]) - B;
        if (j > ans) ans = j;
        B[j] = b[i];
        Len[i] = j;
    }
}

struct Node {
    int pre, last, v, pos;

    Node() {}

    Node(int pre, int last, int v, int pos) : pre(pre), last(last), v(v), pos(pos) {}

    bool operator < (const Node &next) const {
        return v > next.v;
    }
} p[MAXN];

int maxv[MAXN << 2];

void pushup(int pos) {
    maxv[pos] = max(maxv[lson], maxv[rson]);
}

void build(int l, int r, int pos) {
    maxv[pos] = 0;
    if (l == r) return ;
    int mid = (l + r) >> 1;
    build(l, mid, lson);
    build(mid + 1, r, rson);
}

void update(int l, int r, int L, int R, int pos, int v) {
    if (l <= L && R <= r) {
        maxv[pos] = v; return ;
    }
    int mid = (L + R) >> 1;
    if (mid >= l) {
        update(l, r, L, mid, lson, v);
    }
    if (mid < r) {
        update(l, r, mid + 1, R, rson, v);
    }
    pushup(pos);
}

int query(int l, int r, int L, int R, int pos) {
    if (l <= L && R <= r) {
        return maxv[pos];
    }
    int mid = (L + R) >> 1;
    int res = 0;
    if (mid >= l) {
        res = max(res, query(l, r, L, mid, lson));
    }
    if (mid < r) {
        res = max(res, query(l, r, mid + 1, R, rson));
    }
    return res;
}

void work() {
    printf("Case #%d: ", Cas ++);
    scanf("%d %d", &N, &L);
    for (int i = 1; i <= N; i ++) {
        scanf("%d", &a[i]);
        b[i] = Point(a[i]);
    }
    init();
    for (int i = 1; i <= N; i ++) {
        p[i] = Node(len[i], Len[i], a[i], i);
    }
    if (L == N) {
        printf("0\n"); return ;
    }

    int ans = max(p[L + 1].last, p[N - L].pre);
    for (int i = L + 1; i <= N; i ++) {
        ans = max(ans, p[i].last);
    } 
    for (int i = 1; i <= N - L; i ++) {
        ans = max(ans, p[i].pre);
    }
    sort(p + 1, p + 1 + N);
    int pv = p[1].v, l = 1;
    build(1, N, 1);
    for (int i = 1; i <= N; i ++) {
        if (p[i].v != pv) {
            while (l < i) {
                update(p[l].pos, p[l].pos, 1, N, 1, p[l].last);
                l ++;
            }
            pv = p[i].v;
        }
        int pos = p[i].pos;
        if (pos + L + 1 <= N) {
            int pre = p[i].pre;
            int last = query(pos + L + 1, N, 1, N, 1);
            ans = max(ans, pre + last);
        } else if (pos + L == N) {
            int pre = p[i].pre;
            ans = max(ans, pre);
        }
    }
    printf("%d\n", ans);
}
int main() {
#ifdef __SKT__
    freopen("in", "r", stdin);
#endif
    scanf("%d", &T);
    while (T --) {
        work();
    }
    return 0;
}

